﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using OneServiceMultiBinding;
using System.ServiceModel.Description;

using System.Threading;
using System.Net;
using System.IO;
namespace OSMB
{
    class Program
    {
        static void Main(string[] args)
        {
            //rest part
            Uri baseAddress = new Uri("http://localhost:80");

            ServiceHost host = new ServiceHost(typeof(Service1), baseAddress);
            WebHttpBinding binding = new WebHttpBinding();

            ServiceEndpoint endpoint = host.AddServiceEndpoint(typeof(IService1), binding,"shit");
            WebHttpBehavior httpBehavior = new WebHttpBehavior();
            endpoint.Behaviors.Add(httpBehavior);
            host.Open();


            ThreadStart ts = new ThreadStart(() =>
            {
                WebClient wc = new WebClient();
                Stream s = wc.OpenRead(baseAddress.ToString() + "/shit/get/1");
                StreamReader sr = new StreamReader(s);
                Console.WriteLine(sr.ReadToEnd());
                Console.Read();
            });
            Thread t = new Thread(ts);
            t.Start();

            //rest part end

            //soap part

            Uri baseAddress2 = new Uri("net.tcp://localhost:99");

            ServiceHost host2 = new ServiceHost(typeof(Service1), baseAddress2);
            NetTcpBinding binding2 = new NetTcpBinding();

            ServiceEndpoint endpoint2 = host2.AddServiceEndpoint(typeof(IService1), binding2, "shit");
            //WebHttpBehavior httpBehavior2 = new WebHttpBehavior();
            //endpoint2.Behaviors.Add(httpBehavior2);
            host2.Open();


            ThreadStart ts2 = new ThreadStart(() =>
            {
                //BaseClient bc;
                /*WebClient wc = new WebClient();
                Stream s = wc.OpenRead(baseAddress.ToString() + "/shit/get/1");
                StreamReader sr = new StreamReader(s);
                Console.WriteLine(sr.ReadToEnd());
                Console.Read();*/
            });
            Thread t2 = new Thread(ts2);
            t2.Start();


            //soap part end

                        
        }
    }

    /*
     using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WCFLearning2
{
    class Program
    {
        static void Main(string[] args)
        {
            using (System.ServiceModel.ServiceHost host = new System.ServiceModel.ServiceHost(typeof(WCFLearning2.Service)))
            {
                host.Open();
                Console.WriteLine("Service started. press any key to stop it");
                Console.ReadLine();
                host.Close();
            }
        }
    }
}
*/
}
